//加减仓操作（预操作）：/get-position-after-add-or-sub
import http from 'k6/http';
import { sleep } from 'k6';
import { URL } from './config.js';

export const options = {
    vus:10,
    duration:'30s'
};

export default function () {
    //https://api.xiaobeiyangji.com/api/get-position-after-add-or-sub
    const url=`${URL}/api/get-position-after-add-or-sub`;
    const payload=JSON.stringify(
      {
        "data":{"code":"161725","type":"buy","sellTranche":0,"buyMoney":100,"rates":0.1,"fees":0.1,"isBeforeThree":true,"state":"wait","accountId":"c6908502-2d4e-4bbd-828f-a215a4c6cc23","computeDate":"2025-10-24"},
        "date":"2025-10-24",
        "confirm":false,
        "unionId":"o896o5_scUqyJKkRTR1z9Wbm4V98",
        "version":"3.4.0.X"}
    );
  const res = http.post(url,payload,{headers:{'Content-Type': 'application/json' }});
  console.log('状态码:', res.status);   // 200
  console.log('返回体:', res.body);     // 原始字符串
  // sleep() 函数作为多个串联请求的思考时间
  sleep(1);
}